<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
    <link rel="stylesheet" href="../css/login.css">
    <link rel="stylesheet" href="../plugins/layui/css/layui.css">
    <script src="../plugins/jquery/jquery.min.js"></script>
    <script src="../plugins/layui/layui.js"></script>
    <script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
    <script src="../js/bootbox.all.min.js"></script>
    <style>
        a:hover, a:visited {
            text-decoration: none;
            color: white;
        }

        a {
            color: white;
        }

    </style>
</head>
<body>


<section>

    <div class="color"></div>

    <div class="color"></div>

    <div class="color"></div>

    <div class="box">

        <div class="square" style="--i:0;"></div>

        <div class="square" style="--i:1;"></div>

        <div class="square" style="--i:2;"></div>

        <div class="square" style="--i:3;"></div>

        <div class="square" style="--i:4;"></div>

        <div class="container">
            <div class="form">
                <h2>Set NewPassword</h2>
                <form role="form">
                    <!-- 密码 -->
                    <div class="form-group inputBox">
                        <!--                              <label >密码</label>-->
                        <div class="input-group">
                            <div class="addon input-group-addon"><i class="fas fa-lock"></i></div>
                            <input type="text" class="form-control" id="pswd" placeholder="请输入密码">
                        </div>
                    </div>
                    <!-- 再次输入密码 -->
                    <div class="form-group inputBox">
                        <!--                              <label >确认密码</label>-->
                        <div class="input-group">
                            <div class="addon input-group-addon"><i class="fas fa-lock"></i></div>
                            <input type="text" class="form-control" id="repswd" placeholder="请再次输入密码">
                        </div>
                    </div>
                    <!-- 登录按钮 -->
                    <button type="button" class="  login-btn btn-block" id="change">修改</button>
                    <button type="button" style="margin-top: 15px" class="  login-btn btn-block" onclick="gologin()">
                        返回登录
                    </button>
                </form>
            </div>
        </div>

    </div>

</section>
<script>
    function gologin() {
        location.href = "/login.html";
    }

    $("#change").on("click", function () {
        let pswd = $("#pswd").val()
        let repswd = $("#repswd").val()
        if (pswd === repswd) {
            $.ajax({
                url: "changepswd",
                dataType: "json",
                data: {
                    pswd: pswd,
                    repswd: repswd
                },
                success: function (resp) {
                    if (resp === 1) {
                        layer.alert(
                            '修改成功'
                        )
                        location.href = "../login.html"
                    } else {
                        layer.alert(
                            '修改失败'
                        )
                    }
                }
            })
        } else {
            layer.alert("两次输入密码不一致")
        }

    })
</script>
</body>
</html>